<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>选择服务器</title>
    <jsp:include page="common/common_head.jsp"></jsp:include>


</head>
<body  data-spy="scroll" data-target=".navbar">



<jsp:include page="common/common_banner_app.jsp"></jsp:include>
<div style="height:30px"></div>
<div class="container">

    <h4>${title} ${app}(${version}) ${stepName}</h4>

    <div>
        服务器过滤:<input id="filter" value="${params.filter}" /> <button onclick="filter()">过滤</button>

    </div>

    <form action="${nextStep}" id="slaveForm" method="POST">
        <table class="table  table-striped table-bordered table-hover " id = "showTable">

            <thead>
                <tr>
                    <th style="width:40px">
                        <input type="checkbox" onchange="slaveSelect()" id="slaveSelectBtn"/>
                    </th>
                    <th>序号</th>
                    <th>服务器</th>
                    <th>IP</th>
                    <th>CPU</th>
                    <th>内存</th>

                </tr>
                </thead>
                <tbody>
                <c:forEach items="${slave}" var="c" varStatus="v">
                    <tr>
                        <td><input type="checkbox" name="slave" value="${c.hostName}" class="slave"/></td>
                        <td>${v.index + 1}</td>
                        <td>${c.hostName}</td>
                        <td> ${c.ip}</td>
                        <td> ${c.cpuCores}</td>
                        <td> ${c.memory}</td>
                    </tr>
                </c:forEach>
                <tr>
                   <td colspan="6">
                       <input type="hidden" name="version" value="${version}"/>
                       <input type="hidden" name="app" value="${app}"/>
                       <input type="hidden" name="appName" value="${params.appName}"/>
                       <input type="hidden" name="step" value="${step}"/>
                       <c:forEach items="${iterKVs}" var="c">
                           <input type="hidden" name="${c.key}" value="${c.value}"/>
                       </c:forEach>
                       <input type="button" onclick="submitForm()" class="btn" value="提交"/>
                   </td>
                </tr>
            </tbody>

        </table>
    </form>



	<jsp:include page="common/common_js.jsp"></jsp:include>




	<script>

        function submitForm(){

            $("#slaveForm").submit()
        }

        function filter(){
            var url = location.pathname+"?app=${params.app}&nextStep=${params.nextStep}&appName=${params.appName}&version=${params.version}&filter="+$("#filter").val()
            location.href = url;
        }


        function slaveSelect(){


            if($("#slaveSelectBtn").attr("checked") == "checked")
                $(".slave").attr("checked", true)
            else
                $(".slave").attr("checked", false)



        }

	</script>
</body>
</html>